// <copyright file="CarthesianChart.cs" company="YUIAsp.Net">
// Copyright (c) 2009 All Right Reserved
// </copyright>
// <author>raul popescu</author>
// <email>dev@yuiasp.net</email>
// <date>2009-01-30</date>
// <summary>YUIAsp.Net File</summary>

using System.Collections.Generic;
using System.Web.UI;

namespace YUIAspNet
{
    /// <summary>
    /// CarthesianChart implementation.
    /// </summary>
    public abstract class CarthesianChart : BaseChart
    {
        private IList<Series> _series;

        /// <summary>
        /// Register the values to send to the client control for initialization.
        /// Must be overriden in parent control to add client initialization properties and events.
        /// </summary>
        protected override void RegisterClientInitialization()
        {
            base.RegisterClientInitialization();

            AddProperty("Series", Series);
            if (this.XAxis != null)
                AddProperty("XAxis", XAxis);
            if (this.YAxis != null)
                AddProperty("YAxis", YAxis);

            if (!string.IsNullOrEmpty(XField))
                AddProperty("XField", XField);
            if (!string.IsNullOrEmpty(YField))
                AddProperty("YField", YField);
        }

        #region Public Properties
        /// <summary>
        /// Gets or sets the series.
        /// </summary>
        /// <value>The series.</value>
        [PersistenceMode(PersistenceMode.InnerProperty)]
        public IList<Series> Series 
        { 
            get
            {
                if(_series == null)
                    _series = new List<Series>();

                return _series;
            }
        }

        /// <summary>
        /// Gets or sets the X axis.
        /// </summary>
        /// <value>The X axis.</value>
        [PersistenceMode(PersistenceMode.InnerProperty)]
        public ChartAxis XAxis { get; set; }

        /// <summary>
        /// Gets or sets the Y axis.
        /// </summary>
        /// <value>The Y axis.</value>
        [PersistenceMode(PersistenceMode.InnerProperty)]
        public ChartAxis YAxis { get; set; }

        /// <summary>
        /// Gets or sets the X field.
        /// </summary>
        /// <value>The X field.</value>
        public string XField { get; set; }

        /// <summary>
        /// Gets or sets the Y field.
        /// </summary>
        /// <value>The Y field.</value>
        public string YField { get; set; } 
        #endregion
    }
}
